/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.pol.tesis.ii.wsrest;

import com.sun.jersey.api.view.Viewable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.log4j.Logger;

/**
 * REST Web Service
 *
 * @author Leandro
 */
@Path("menu")
@Stateless
public class MenuResource {

    @Context
    private UriInfo context;

    public MenuResource() {        
    }
    
    @GET
    @Path("/index")
    @Produces("text/html")
    public Response index(@Context HttpServletRequest req) {
        Map<String, Object> map = new HashMap<String, Object>();
        try {
            HttpSession session = req.getSession(true);
            Logger.getLogger("").info("Session, MenuResource.index: " + session.getId());
            
            List<String> permisos = new ArrayList<String>();
            permisos.add("P1");
            permisos.add("P2");
            permisos.add("P3");
            permisos.add("P4");
            
            map.put("permisos", permisos);
            map.put("usuario", "leandrol");
        } catch (Exception e) {
            Logger.getLogger("").info("Error al mostrar el ui menu: ", e);
        }

        return Response.ok(new Viewable("/menu", map)).build();
    }
   
}
